﻿using SCG.General;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TTEngine
{
    public static class ConditionFactory
    {
        //static constructor
        static ConditionFactory()
        {
            TypeLoader loader = new TypeLoader("Condition", "");
            foreach (Type t in loader.Types)
            {
                Condition c = (Condition)loader.CreateInstance(t);
                _templates.Add(c);
            }
        }

        //return an instance
        public static Condition GetCondition(string name)
        {
            name = name.ToUpper();
            foreach (Condition c in _templates)
                if (c.ConditionName.ToUpper() == name)
                    return c.Clone();
            return null;
        }

        //private members
        private static List<Condition> _templates = new List<Condition>();
    }
}
